/**
 *
 */
package com.ybkj.daijia.server.service.impl;

import com.ybkj.daijia.server.mapper.MemberMapper;
import com.ybkj.daijia.server.service.MemberAccountService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author Shine
 *
 */
@Service
public class DefaultMemberAccountService implements MemberAccountService {

    @Autowired
    private MemberMapper memberMapper;

//	public Page<MemberAccount> queryAll(Long memberId) {
//		
//		Pageable pageable = new PageRequest(Pager.getPage(), Pager.getLimit());
//		
//		List<MemberAccount> content = memberAccountMapper.selectByMemberPage(memberId, Pager.getOffset(), Pager.getLimit());
//		long total = memberAccountMapper.countByMemberPage(memberId);
//		
//		return new PageImpl<MemberAccount>(content, pageable, total);
//	}

//	@Transactional(rollbackFor=Exception.class)
//	public MemberAccount insertRecord(MemberAccount memberAccount) {
//		
//		if(StringUtils.isNotBlank(memberAccount.getPhone())){
//			memberAccount.setPhone(memberAccount.getPhone().replaceAll(" ", ""));
//		}
//		memberAccountMapper.insertRecord(memberAccount);
//	
//		return memberAccount;
//	}

//	@Override
//	@Transactional(rollbackFor=Exception.class)
//	public int updateByPrimaryKey(MemberAccount record) {
//		
//		if(StringUtils.isNotBlank(record.getPhone())){
//			record.setPhone(record.getPhone().replaceAll(" ", ""));
//		}
//		
//		return memberAccountMapper.updateByPrimaryKey(record);
//	}

//	public MemberAccount findByPhone(String phone) {
//		
//		return memberAccountMapper.selectByPhone(phone);
//	}

//	@Transactional(rollbackFor=Exception.class)
//	public void delete(MemberAccount memberAccount) {
//		
//		memberAccountMapper.deleteByPrimaryKey(memberAccount.getId());
//		
//	}

//	@Transactional(rollbackFor=Exception.class)
//	public void deleteByMember(Long memberId) {
//		
//		memberAccountMapper.deleteByMember(memberId);
//		
//	}

//	@Override
//	public MemberAccount findOne(Long id) {
//		
//		return memberAccountMapper.selectByPrimaryKey(id);
//	}

//	@Override
//	public List<MemberAccount> queryMemberByPhone(String phone) {
//		
//		Subject currentUser = SecurityUtils.getSubject();
//		
//		Principal principal = (Principal) currentUser.getPrincipal();
//		
//		Map<String, Object> params = new HashMap<String, Object>();
//		params.put("offset", 0);
//		params.put("size", 10);
//		if(!principal.isCompanyType()){
//			params.put("companyId", principal.getCompanyId());
//		}
//		if(StringUtils.isNotBlank(phone)){
//			params.put("phone", "%"+phone+"%");
//		}
//		
//		List<MemberAccount> content = memberAccountMapper.selectByPage(params);
//		if(!CollectionUtils.isEmpty(content)){
//			for (MemberAccount memberAccount : content) {
//				memberAccount.setMember(memberMapper.selectByPrimaryKey(memberAccount.getMemberId()));
//			}
//		}
//		
//		return content;
//	}

//	@Transactional(rollbackFor=Exception.class)
//	public void updateDevice(final String cid) {
//		
//		memberAccountMapper.updateByCidNullWithCid(cid);
//
//	}

//	@Override
//	public List<MemberAccount> findByMember(Long memberId) {
//		
//		return memberAccountMapper.selectByMember(memberId);
//	}
//
//	@Override
//	public List<MemberAccount> findByPhoneLike(String phone) {
//		return memberAccountMapper.selectByPhoneLike("%"+phone+"%");
//	}

}